<template>
  <div>
    <h1>基本信息</h1>
    <el-form class="commonFrom" label-width="auto">
      <el-form-item label="招标编号：">
        {{ biddFrom.biddingNo }}
      </el-form-item>
      <el-form-item label="关联工程："> {{ biddFrom.proName }}</el-form-item>
      <el-form-item label="招标单位：">
        {{ biddFrom.biddingEnterprise }}
      </el-form-item>
      <el-form-item label="预估总价："> {{ biddFrom.estimateTotalPrice }}(万元) </el-form-item>
      <el-form-item label="交付地点：" style="margin-right: 400px">
        {{ biddFrom.province }}{{ biddFrom.city }}{{ biddFrom.area }}{{ biddFrom.detailAddress }}
      </el-form-item>
      <el-form-item label="投标截止时间：" style="margin-right: 400px"> {{ biddFrom.bidDateline }}</el-form-item>
      <el-form-item label="招标内容：">
        <span v-for="(item, index) in biddFrom.addBiddingContentDtoList" :key="item.id">
          {{ item.materialName }}{{ index + 1 === biddFrom.addBiddingContentDtoList.length ? '' : ';' }}
        </span>
      </el-form-item>
    </el-form>
    <div style="margin-top: 7px">
      <el-button style="width: 130px" class="commonBtn1" @click="batchMore"> 全部好评 </el-button>
      <span style="margin-left: 10px; font-size: 14px; color: #999"
        >注：若对所有供应商都满意，点击全部为所有报价供应商进行满分评价。</span
      >
    </div>
    <div class="ebalua_wrap" v-for="(item, index) in batchList" :key="index">
      <bidding-evaluation
        :moreEvalua="true"
        :evaObj="item"
        :bidEnterpriseId="item.enterpriseId"
        :bidid="bidid"
        :evaluateType="1"
      >
      </bidding-evaluation>
    </div>
    <div class="evabtn">
      <el-button style="width: 130px" class="commonBtn1" @click="closeBtn"> 关闭 </el-button>
    </div>
  </div>
</template>

<script>
import BiddingEvaluation from '../../../../components/BiddingEvaluation.vue'
export default {
  components: { BiddingEvaluation },
  props: {
    bidid: {
      type: [String, Number],
      require: true
    }
  },
  data() {
    return {
      batchList: [],
      biddFrom: {}
    }
  },
  mounted() {
    this.getData()
    this.getBidding()
  },
  methods: {
    getData() {
      this.$https({
        method: 'post',
        url: '/evaluate/listEvaluateInfo',
        data: {
          enterpriseId: null,
          evaluateRecordId: this.bidid,
          evaluateType: 1
        }
      })
        .then(res => {
          if (res.code === 0) {
            this.batchList = res.data
          } else {
            this.$message.error(res.msg)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    getBidding() {
      this.$https({
        method: 'post',
        url: '/purchaseAdmin/biddingInfoById/?id=' + this.bidid
      })
        .then(res => {
          if (res.code === 0) {
            this.biddFrom = res.data
          } else {
            this.$message.error(res.msg)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    closeBtn() {
      this.$emit('close')
    },
    batchMore() {
      this.batchList.forEach(item => {
        item.biddingAbilityPerformance = 5
        item.biddingCooperationDegree = 5
        item.biddingEnterpriseReputation = 5
        item.biddingRationQuote = 5
        item.biddingTruthQuote = 5
        item.evaluateRecordId = this.bidid
        item.purchaserId = +localStorage.getItem('enterpriseId')
        item.labeiId = [1, 2, 3, 4, 5]
        item.evaluateContent = '默认好评'
      })
      this.$https({
        method: 'post',
        url: '/evaluate/biddingEvaluate',
        data: this.batchList
      })
        .then(res => {
          if (res.code == 0) {
            this.$message.success('评价成功')
            this.getData()
          } else {
            this.$message.error(res.msg)
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
</script>
<style lang="less" scoped>
.ebalua_wrap {
  padding: 25px 40px;
  border: 1px solid #d6d6d6;
  margin-top: 20px;
}
.evabtn {
  margin: 40px 0 0;
  display: flex;
  justify-content: center;
}
.commonFrom {
  margin-top: 7px;
  width: 88%;
  .el-form-item {
    width: 40% !important;
    margin-bottom: 7px !important;
  }
  .form-item {
    width: 100% !important;
    /deep/.el-form-item__content {
      display: flex;
    }
    .el-input {
      width: 260px;
    }
  }

  .performance_text {
    color: #999;
    font-size: 14px;
  }
  .icon-guanbianniu {
    font-size: 16px;
    cursor: pointer;
    margin-left: 10px;
  }
  .icon-guanbianniu:hover {
    color: #fa7355;
  }
}
h1 {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  padding-left: 10px;
  border-left: 4px solid #fa7355;
  span {
    font-weight: normal;
    color: #999;
  }
}
.ty {
  color: #ff3d3d;
}
</style>
